package dipl.algorithm.math.fp.geometry;

import dipl.algorithm.math.fp.primitive.Point2df;

/**
 * Class returned by bridge calculation. It stores a bridge between two convex polygons
 */
public class Bridge2d {

	//
	// CONSTRUCTOR METHODS
	//

	public Bridge2d( Point2df[] poly1, int i, Point2df[] poly2, int j ) {
		this.poly1 = poly1;
		this.i = i;
		this.poly2 = poly2;
		this.j = j;
	}

	//
	// PUBLIC METHODS
	//

	/**
	 * Swaps contents of bridge: (p1,i,p2,j) -> (p2,j,p1,i)
	 */
	public void Swap() {
		Point2df[] tp = poly1; poly1 = poly2; poly2 = tp;
		int t = i; i = j; j = t;
	}

	/**
	 * @return string representation
	 */
	@Override
	public String toString() {
		return "("+Integer.toString( i )+","+Integer.toString( j )+")";
	}

	//
	// PROPERTIES
	//

	/**
	 * @return first bridge point
	 */
	public Point2df P1() {
		return poly1[i];
	}

	/**
	 * @return Returns second bridge point
	 */
	public Point2df P2() {
		return poly2[j];
	}

	//
	// MEMBERS
	//

	/**
	 * first polygon
	 */
	public Point2df[] poly1;
	/**
	 * starting point index
	 */
	public int i;
	/**
	 * last polygon
	 */
	public Point2df[] poly2;
	/**
	 * ending point index
	 */
	public int j;
}